package tools.vcf.bisSNP;

public class BisSNPbedEntry {

	private String chr;
	private int start,stop;
	private int cCount,tCount;
	private boolean passed;
	
	
	final static String dot=".";

	public BisSNPbedEntry(String chr, int start, int stop, int cCount,
			int tCount, boolean passed) {
		super();
		this.chr = chr;
		this.start = start;
		this.stop = stop;
		this.cCount = cCount;
		this.tCount = tCount;
		this.passed = passed;
	}
	
	public BisSNPbedEntry(BisSNPbedEntry bsbe){
		this(bsbe.chr, bsbe.start, bsbe.stop, bsbe.cCount, bsbe.tCount, bsbe.passed);
	}

	public BisSNPbedEntry(String vcfLine)throws Exception{
		String[] l= vcfLine.split("\t"), k= l[9].split(":");
		this.chr= l[0];
		this.stop= Integer.parseInt(l[1]);
		this.start= this.stop-1;
		this.passed= l[6].equals("PASS");
		if(dot.equals(k[3]) || dot.equals(k[5])){
			throw new Exception("Not a methylated site");
		}
		this.cCount= Integer.parseInt(k[3]);
		this.tCount= Integer.parseInt(k[5]);
	}
	
	public int getCoverage(){
		return this.cCount+this.tCount;
	}
	
	public double getMethylation(){
		return ((double)this.cCount)/this.getCoverage();
	}
	
	public String getChr() {
		return chr;
	}
	public int getStart() {
		return start;
	}
	public int getStop() {
		return stop;
	}
	public int getcCount() {
		return cCount;
	}
	public int gettCount() {
		return tCount;
	}
	public boolean isPassed() {
		return passed;
	}

	protected void setChr(String chr) {
		this.chr = chr;
	}
	protected void setStart(int start) {
		this.start = start;
	}
	protected void setStop(int stop) {
		this.stop = stop;
	}
	protected void setcCount(int cCount) {
		this.cCount = cCount;
	}
	protected void settCount(int tCount) {
		this.tCount = tCount;
	}
	protected void setPassed(boolean passed) {
		this.passed = passed;
	}
	
	
}
